package com.atguigu.lease.common.context;

//定义ThreadLocal工具类
public class LoginUserContext {
    private static ThreadLocal<LoginUser> threadLocal = new ThreadLocal<>();
    //让当前线程存储数据
    public static void setThreadLocal(LoginUser loginUser){
        threadLocal.set(loginUser);
    }
    //从当前线程中获取数据
    public static LoginUser getLoginUser(){
        LoginUser loginUser = threadLocal.get();
        return loginUser;
    }
    //从当前线程中移除数据
    public static void removeLoginUser(){
        threadLocal.remove();
    }
}
